package ar.pmt.vista.acciones;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import ar.pmt.core.constantes.Constantes;
import ar.pmt.vista.beans.Usuario;
import ar.pmt.vista.utils.Utils;

/**
 * @author gburgener
 */
public class Iniciar extends Action {

	/**
	 * @param mapping ActionMapping
	 * @param form ActionForm
	 * @param request HttpServletRequest
	 * @param response HttpServletResponse
	 * @return ActionForward
	 * @throws Exception control general de errores de la aplicacion
	 */
   public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
         HttpServletResponse response) throws Exception {

	   ActionForward action = null;
	   Usuario usuario = Utils.obtenerUsuario(request);

	   if (usuario.getCodigoPerfil().equals("ADM")) {
		   action = mapping.findForward("admin");
	   } else {
		   action = mapping.findForward("programador");
	   }
	   request.getSession().setAttribute(Constantes.ESTADO_IMPORTACION, Constantes.IMPORTACION_NINGUNO );

	   return action;
   }

}